//@author A0105511Y
#include "IntegrationTest.h"

//test for usercommand - add
TEST_F(IntegrationTest, IntegrationTest_Add) {
	string todayDate = getTodayDate();
	string userCommand = "add [Task 1][" + todayDate + "][0700][1700][untagged]";
	logic->processUserCommand(userCommand);
	updateDisplay();
	
	expectedMainDisplay.push_back(Task("Task 1", todayDate, "0700", "1700", "untagged").toString());
	
	ASSERT_EQ(expectedMainDisplay, mainDisplay);
	ASSERT_EQ(expectedDoneDisplay, doneDisplay);
}

//test for usercommand - undo(add)
TEST_F(IntegrationTest, IntegrationTest_Undo_Add) {
	string todayDate = getTodayDate();
	string userCommand = "add [Task 1][" + todayDate + "][0700][1700][untagged]";
	logic->processUserCommand(userCommand);	
	userCommand = "add [Task 2][today][1800][2000][3]";
	logic->processUserCommand(userCommand);
	userCommand = "undo";
	logic->processUserCommand(userCommand);
	updateDisplay();

	expectedMainDisplay.push_back(Task("Task 1", todayDate, "0700", "1700", "untagged").toString());

	ASSERT_EQ(expectedMainDisplay, mainDisplay);
	ASSERT_EQ(expectedDoneDisplay, doneDisplay);
}


//test for usercommand - delete
TEST_F(IntegrationTest, IntegrationTest_Delete) {
	string todayDate = getTodayDate();
	string userCommand = "add [Task 1][" + todayDate + "][0700][1700][untagged]";
	logic->processUserCommand(userCommand);	
	userCommand = "add [Task 2][today][1800][2000][3]";
	logic->processUserCommand(userCommand);
	userCommand = "delete 2";
	logic->processUserCommand(userCommand);
	updateDisplay();
	
	expectedMainDisplay.push_back(Task("Task 1", todayDate, "0700", "1700", "untagged").toString());
	
	ASSERT_EQ(expectedMainDisplay, mainDisplay);
	ASSERT_EQ(expectedDoneDisplay, doneDisplay);
}

//test for ussercommand - undo(delete)
TEST_F(IntegrationTest, IntegrationTest_Undo_Delete) {
	string todayDate = getTodayDate();
	string userCommand = "add [Task 1][" + todayDate + "][0700][1700][untagged]";
	logic->processUserCommand(userCommand);	
	userCommand = "add [Task 2][today][1800][2000][3]";
	logic->processUserCommand(userCommand);
	userCommand = "delete 2";
	logic->processUserCommand(userCommand);
	userCommand = "undo";
	logic->processUserCommand(userCommand);
	updateDisplay();
	
	expectedMainDisplay.push_back(Task("Task 1", todayDate, "0700", "1700", "untagged").toString());
	expectedMainDisplay.push_back(Task("Task 2", todayDate, "1800", "2000", "3").toString());

	ASSERT_EQ(expectedMainDisplay, mainDisplay);
	ASSERT_EQ(expectedDoneDisplay, doneDisplay);
}

//test for usercommand - done
TEST_F(IntegrationTest, IntegrationTest_Done) {
	string todayDate = getTodayDate();
	string userCommand = "add [Task 1][" + todayDate + "][0700][1700][untagged]";
	logic->processUserCommand(userCommand);	
	userCommand = "add [Task 2][today][1800][2000][3]";
	logic->processUserCommand(userCommand);
	userCommand = "done 2";
	logic->processUserCommand(userCommand);
	updateDisplay();
	
	expectedMainDisplay.push_back(Task("Task 1", todayDate, "0700", "1700", "untagged").toString());
	expectedDoneDisplay.push_back(Task("Task 2", todayDate, "1800", "2000", "3").toString());
	
	ASSERT_EQ(expectedMainDisplay, mainDisplay);
	ASSERT_EQ(expectedDoneDisplay, doneDisplay);
}

//test for usercommand - undo(done)
TEST_F(IntegrationTest, IntegrationTest_Undo_Done) {
	string todayDate = getTodayDate();
	string userCommand = "add [Task 1][" + todayDate + "][0700][1700][untagged]";
	logic->processUserCommand(userCommand);	
	userCommand = "add [Task 2][today][1800][2000][3]";
	logic->processUserCommand(userCommand);
	userCommand = "done 2";
	logic->processUserCommand(userCommand);
	userCommand = "undo";
	logic->processUserCommand(userCommand);
	updateDisplay();
	
	expectedMainDisplay.push_back(Task("Task 1", todayDate, "0700", "1700", "untagged").toString());
	expectedMainDisplay.push_back(Task("Task 2", todayDate, "1800", "2000", "3").toString());
	
	ASSERT_EQ(expectedMainDisplay, mainDisplay);
	ASSERT_EQ(expectedDoneDisplay, doneDisplay);
}

//test for usercommand - modify
TEST_F(IntegrationTest, IntegrationTest_Modify) {
	string todayDate = getTodayDate();
	string userCommand = "add [Task 1][" + todayDate + "][0700][1700][untagged]";
	logic->processUserCommand(userCommand);	
	userCommand = "add [Task 2][today][1800][2000][3]";
	logic->processUserCommand(userCommand);
	userCommand = "modify 1";
	logic->processUserCommand(userCommand);
	userCommand = "to [Task 3][today][0900][1500][school]";
	logic->processUserCommand(userCommand);
	updateDisplay();
	
	expectedMainDisplay.push_back(Task("Task 3", todayDate, "0900", "1500", "school").toString());
	expectedMainDisplay.push_back(Task("Task 2", todayDate, "1800", "2000", "3").toString());
	
	ASSERT_EQ(expectedMainDisplay, mainDisplay);
	ASSERT_EQ(expectedDoneDisplay, doneDisplay);
}

//test for usercommand - undo(modify)
TEST_F(IntegrationTest, IntegrationTest_Undo_Modify) {
	string todayDate = getTodayDate();
	string userCommand = "add [Task 1][" + todayDate + "][0700][1700][untagged]";
	logic->processUserCommand(userCommand);	
	userCommand = "add [Task 2][today][1800][2000][3]";
	logic->processUserCommand(userCommand);
	userCommand = "modify 1";
	logic->processUserCommand(userCommand);
	userCommand = "to [Task 3][today][0900][1500][school]";
	logic->processUserCommand(userCommand);
	userCommand = "undo";
	logic->processUserCommand(userCommand);
	updateDisplay();
	
	expectedMainDisplay.push_back(Task("Task 1", todayDate, "0700", "1700", "untagged").toString());
	expectedMainDisplay.push_back(Task("Task 2", todayDate, "1800", "2000", "3").toString());
	
	ASSERT_EQ(expectedMainDisplay, mainDisplay);
	ASSERT_EQ(expectedDoneDisplay, doneDisplay);
}

//test for usercommand - search
TEST_F(IntegrationTest, IntegrationTest_Search) {
	string todayDate = getTodayDate();
	string userCommand = "add [Task 1][" + todayDate + "][0700][1700][untagged]";
	logic->processUserCommand(userCommand);	
	userCommand = "add [Task 2][today][1800][2000][3]";
	logic->processUserCommand(userCommand);
	userCommand = "modify 1";
	logic->processUserCommand(userCommand);
	userCommand = "to [Task 3][today][0900][1500][school]";
	logic->processUserCommand(userCommand);
	userCommand = "done 2";
	logic->processUserCommand(userCommand);
	userCommand = "search 3";
	logic->processUserCommand(userCommand);
	updateDisplay();
	
	expectedMainDisplay.push_back(Task("Task 3", todayDate, "0900", "1500", "school").toString());
	expectedDoneDisplay.push_back(Task("Task 2", todayDate, "1800", "2000", "3").toString());
	
	ASSERT_EQ(expectedMainDisplay, mainDisplay);
	ASSERT_EQ(expectedDoneDisplay, doneDisplay);
}